/*
* Mencoder opts analysis with reference MPlayer doc.	
* author pengl 
* 
*/


#include "StdAfx.h"
#include ".\h264_mencoder.h"

//////////////////////////////////////////////////////////////////////////
/*
 *	Opts variable defined here
 */
//////////////////////////////////////////////////////////////////////////

//subq
static int GOpts_subq[] ={ 4, 5, 6 };
#define GSum_subq  (sizeof(GOpts_subq)/sizeof(int))

//frameref
static int GOpts_frameref[] = { 1, 2, 3 };
#define GSum_frameref (sizeof(GOpts_frameref)/sizeof(int))

//me
static char *GOpts_me[] = { "dia", "hex", "umh" };
#define GSum_me 3

//partitions
static char *GOpts_partitions = "all";

//bframes
static int GOpts_bframes[3] = {2, 3, 5};


static char g_opts_menc[512] = {0};

//////////////////////////////////////////////////////////////////////////
// API
//////////////////////////////////////////////////////////////////////////
void GetFileFormat(const char *fname)
{
	char command[1024] = {0};

	sprintf(command, "mplayer -vo null -ao null -frames 0 -identify %s", fname);


}






/************************************************************************/
/* class implements                                                                     */
/************************************************************************/
CH264_mencoder::CH264_mencoder(void)
{
	m_opts = g_opts_menc;
}

CH264_mencoder::CH264_mencoder(PsX264_opts opts)
{
	m_x264opts = *opts;
}

CH264_mencoder::CH264_mencoder(MENC_H264_QUALITY quality)
{
	m_quality = quality;
	m_opts = g_opts_menc;
}

CH264_mencoder::~CH264_mencoder(void)
{
	m_opts = NULL;
}

const char *CH264_mencoder::get_ffvideo_codecs(const char *v_name, const int index)
{
	//super key word was only compiled with MS C++ compiler, GNU not support
        return CMencoderopts::get_ffvideo_codecs(v_name, index);
}

const char *CH264_mencoder::get_mencoder_opts(MENC_H264_QUALITY quality)
{
	int subq;
	int frameref;
	int bframes;
	
	switch (quality) {
	case H264_FAST_Q:
		subq = GOpts_subq[0];
		frameref = GOpts_frameref[0];
		bframes = GOpts_bframes[0];
		break;
	case H264_H_Q:
		subq = GOpts_subq[1];
		frameref = GOpts_frameref[1];
		bframes = GOpts_bframes[1];
		break;

	case H264_VH_Q:
		subq = GOpts_subq[1];
		frameref = GOpts_frameref[1];
		bframes = GOpts_bframes[1];
		break;

	default:		
		subq = GOpts_subq[0];
		frameref = GOpts_frameref[0];
		bframes = GOpts_bframes[0];
		break;
	};
	
	sprintf(m_opts, H264_immobile_opts, subq, frameref, bframes);	
	return m_opts;
}
